
from typing import List, Optional
from pydantic import BaseModel
from src.enum.result import ContainerEventTypeEnum, ResultDataTypeEnum, TransportModeEnum
from src.model.crawler import ResultDataBase


class ContainerEvent(BaseModel):
    """集装箱事件"""
    event_no: int=0
    event_type: ContainerEventTypeEnum=ContainerEventTypeEnum.HISTORY
    event_time: Optional[str]= None
    place_of_activity: Optional[str]= None
    event_status: Optional[str]= None
    transport: Optional[str]= None
    voyage_info: Optional[str]= None


class ContainerInfo(BaseModel):
    """集装箱信息"""

    container_code: Optional[str]= None
    container_type: Optional[str]= None
    description: Optional[str]= None
    payload: Optional[str]= None
    tare: Optional[str]= None
    dimension: Optional[str]= None
    last_movement: Optional[str] = None
    is_arrived: int=0
    event_list: List[ContainerEvent]=[]


class VoyageInfo(BaseModel):
    """航程信息"""
    voyage_no: int = 0
    transport_mode: Optional[TransportModeEnum]= None
    ship_name: Optional[str]= None
    ship_alias: Optional[str]= None
    ship_mmsi: Optional[str]= None
    ship_imo: Optional[str]= None
    voyage_line: Optional[str]= None
    voyage_number: Optional[str]= None
    orig_port_address: Optional[str]= None
    orig_port_country: Optional[str]= None
    orig_port_code: Optional[str]= None
    dest_port_address: Optional[str]= None
    dest_port_country: Optional[str]= None
    dest_port_code: Optional[str]= None
    ship_etd: Optional[str]= None
    ship_atd: Optional[str]= None
    ship_eta: Optional[str]= None
    ship_ata: Optional[str]= None
    description: Optional[str]= None


class OblResult(ResultDataBase):
    data_type: ResultDataTypeEnum = ResultDataTypeEnum.BILL_OF_LADING
    type_version: str = "v2"
    is_over: int = 0
    origin: Optional[str] = None
    origin_country: Optional[str]= None
    destination: Optional[str]= None
    destination_country: Optional[str]= None
    container_num: int = 0
    container_list: List[ContainerInfo]= []
    voyage_list: List[VoyageInfo]=[]
